﻿using System;
using System.Linq;
using System.Diagnostics;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using DoubleLinkedList;

namespace UnitTest_DoubleLinkedList
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestIfEmpty()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            Assert.AreEqual(true, dll.isEmpty());
        }
        [TestMethod]
        public void TestAddFirst()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            dll.AddFirst(x);
            Assert.AreEqual(10, dll.Front());
            dll.AddFirst(y);
            Assert.AreEqual(20, dll.Front());
            dll.AddFirst(z);
            Assert.AreEqual(30, dll.Front());
        }
        [TestMethod]
        public void TestAddLast()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            dll.AddLast(x);
            Assert.AreEqual(10, dll.Last());
            dll.AddLast(y);
            Assert.AreEqual(20, dll.Last());
            dll.AddLast(z);
            Assert.AreEqual(30, dll.Last());
        }
        [TestMethod]
        public void TestClear()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            dll.AddFirst(x);
            dll.AddFirst(y);
            dll.AddFirst(z);
            dll.Clear();
            Assert.AreEqual(true, dll.isEmpty());

        }
        [TestMethod]
        public void TestContains()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            dll.AddFirst(x);
            dll.AddFirst(y);
            dll.AddFirst(z);
            Assert.AreEqual(true, dll.Contains(y));
            Assert.AreEqual(false, dll.Contains(40));
        }
        [TestMethod]
        public void TestFind()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            dll.AddFirst(x);
            dll.AddFirst(y);
            dll.AddFirst(z);
            Assert.AreEqual(20, dll.Find(20));
        }
        [TestMethod]
        public void TestRemove()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            int q = 40;
            dll.AddFirst(x);
            dll.AddFirst(y);
            dll.AddFirst(z);
            dll.AddFirst(q);
            Assert.AreEqual(true, dll.Remove(z));
        }
        [TestMethod]
        public void TestRemoveFirst()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            dll.AddFirst(x);
            dll.AddFirst(y);
            dll.AddFirst(z);
            dll.RemoveFirst();
            Assert.AreEqual(y, dll.First());
        }
        [TestMethod]
        public void TestRemoveLast()
        {
            DoubleLinked<int> dll = new DoubleLinked<int>();
            int x = 10;
            int y = 20;
            int z = 30;
            dll.AddFirst(x);
            dll.AddFirst(y);
            dll.AddFirst(z);
            dll.RemoveLast();
            Assert.AreEqual(y, dll.Last());
        }
    }
}
